#pragma once
#include "d3dApp.h"
#include "d3dUtil.h"
#include "BasicApplication.h"
#include "Vertex.h"


class LightingDemo : public BasicApplication
{
public:
	LightingDemo(HINSTANCE hInstance, std::string caption);
	~LightingDemo(void);
	virtual void updateScene(float dt);
	virtual void onLostDevice();
	virtual void onResetDevice();
protected:
	virtual void draw();
private:
	void LightingDemo::genSphericalTexCoords();

	ID3DXMesh *m_teapot;
	ID3DXMesh *m_grid;
	IDirect3DTexture9 *m_teapotTexture;
	IDirect3DTexture9 *m_gridTexture;

	ID3DXEffect *m_effect;
	D3DXHANDLE m_hSpotLightTech;

	D3DXHANDLE m_hWorldViewProj;
	D3DXHANDLE m_hWorldInvTrans;
	D3DXHANDLE m_hWorld;

	D3DXHANDLE m_hAmbientLight;
	D3DXHANDLE m_hDiffuseLight;
	D3DXHANDLE m_hSpecularLight;
	D3DXHANDLE m_hAmbientMtrl;
	D3DXHANDLE m_hDiffuseMtrl;
	D3DXHANDLE m_hSpecularMtrl;
	D3DXHANDLE m_hSpecularPower;

	D3DXHANDLE m_hEyePosition;
	D3DXHANDLE m_hLightPosition;
	D3DXHANDLE m_hLightDir;
	D3DXHANDLE m_hSpotPower;
	D3DXHANDLE m_hTexture0;

	D3DXVECTOR3 m_lightPosition;

	Mtrl m_matetial;
};

